<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Vue</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/css/common.css">
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
</head>
<body>
<div id="app">
    <h3>{{title}}</h3>
    <button @click="doCalculate">计算</button>
    <div>总价: {{total}}</div>
</div>
<script type="text/javascript">
    const myMinxins = {
        data: {
            price: 2.0,
            count: 5,
            total: '-'
        },
        methods: {
            doCalculate () {
                this.total = (this.price * this.count).toFixed(2)
            }
        }
    }
    const app = new Vue({
        el: '#app',
        data: {
            title: '计算价格'
        },
        mixins: [myMinxins]
    })
</script>
</body>
</html>
